#include "room.hpp"

void buildRoom(int x, int y, int width, int length){
    SDL_Color color = {255, 255, 255, 255};
    // draw horizontal edges;
    for(int i=0;i<width;i++){
        Solid* solid = new Solid(Names::WALL_HORI);
        solid->SetPosition(x+i, y);
        solid->SetColor(color);
        worldmodel.RegistObject(solid);
        worldmodel.GetLayer()->AddObject(solid);

        solid = new Solid(Names::WALL_HORI);
        solid->SetPosition(x+i, y+length-1);
        solid->SetColor(color);
        worldmodel.RegistObject(solid);
        worldmodel.GetLayer()->AddObject(solid);
    }
    // draw vertical edges;
    for(int j=1;j<length-1;j++){
        Solid* solid = new Solid(Names::WALL_VERT);
        solid->SetPosition(x, y+j);
        solid->SetColor(color);
        worldmodel.RegistObject(solid);
        worldmodel.GetLayer()->AddObject(solid);

        solid = new Solid(Names::WALL_VERT);
        solid->SetPosition(x+width-1, y+j);
        solid->SetColor(color);
        worldmodel.RegistObject(solid);
        worldmodel.GetLayer()->AddObject(solid);
    }
    // draw ground
    for(int i=1;i<width-1;i++)
        for(int j=1;j<length-1;j++){
            Ground* ground = new Ground;
            ground->SetPosition(x+i, y+j);
            ground->SetColor(color);
            worldmodel.RegistObject(ground);
            worldmodel.GetLayer()->AddObject(ground);
        }
}
